package com.leilei.MyObject;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created by yvdedu.com on 2016/10/18.
 */
@Entity
@GenericGenerator(name = "getUserId",strategy = "foreign",parameters = {
        @Parameter(name = "property",value = "user")
})
public class UserInfo implements Serializable {
    @Id
    @GeneratedValue(generator = "getUserId")
    private int id;
    private String nickName;
    private String photo;
    private int age;
    private String sex;
    private String intro;
    private int role;
    @JsonIgnore
    @OneToOne
    @JoinColumn(nullable = false)
    private  User user;

    public UserInfo() {
    }

    public UserInfo(String nickName, String photo, int age, String sex, String intro, int role, User user) {
        this.nickName = nickName;
        this.photo = photo;
        this.age = age;
        this.sex = sex;
        this.intro = intro;
        this.role = role;
        this.user = user;
    }
    @JsonIgnore
    public int getId() {

        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public int getRole() {
        return role;
    }

    public void setRole(int role) {
        this.role = role;
    }

    @JsonIgnore
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
